package com.example.jh352160.surfingtv.Index.customView;

import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.bumptech.glide.Glide;
import com.example.jh352160.surfingtv.Index.childpage.AllCategory;
import com.example.jh352160.surfingtv.R;
import com.example.jh352160.surfingtv.thematic_details.ThematicDetailsPage;

/**
 * Created by jh352160 on 2016/7/20
 */

public class IndexColumnBigImage extends RelativeLayout {

    ImageView title, bigImageView, more;
    Context context;

    public IndexColumnBigImage(final Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
        LayoutInflater.from(context).inflate(R.layout.index_column_big_image, this);
        title = (ImageView) findViewById(R.id.index_column_title);
        bigImageView = (ImageView) findViewById(R.id.index_column_big_image);
        more = (ImageView) findViewById(R.id.more);
        //title.setImageResource(titleImage);
        title.setImageResource(R.drawable.index_column_title1);
//        bigImageView.setImageResource(bigImage);
        bigImageView.setImageResource(R.drawable.index_column_big_image2);

    }

    public void setImage(int titleImage, String bigImage, final int adType, final int contentId) {
//        bigImageView.setImageResource(bigImage);
        Glide.with(context).load(bigImage).into(bigImageView);
        title.setImageResource(titleImage);

        bigImageView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(context, ThematicDetailsPage.class);
                intent.putExtra("contentId", contentId);
                context.startActivity(intent);
            }
        });

        more.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(context, AllCategory.class);
                intent.putExtra("category", adType);
                context.startActivity(intent);
            }
        });
    }

}
